package com.xingfudazi.web.controller.app;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.xingfudazi.app.domain.AppMomentLike;
import com.xingfudazi.app.service.IAppMomentLikeService;
import com.xingfudazi.common.annotation.Log;
import com.xingfudazi.common.core.controller.BaseController;
import com.xingfudazi.common.core.domain.AjaxResult;
import com.xingfudazi.common.core.domain.Result;
import com.xingfudazi.common.core.page.TableDataInfo;
import com.xingfudazi.common.enums.BusinessType;
import com.xingfudazi.common.utils.poi.ExcelUtil;
import org.apache.ibatis.annotations.Delete;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 动态-喜欢Controller
 *
 * @author ruoyi
 * @date 2024-06-21
 */
@RestController
@RequestMapping("/app/like")
public class AppMomentLikeController extends BaseController {
    @Autowired
    private IAppMomentLikeService appMomentLikeService;

    /**
     * 查询动态-喜欢列表
     */
    @GetMapping("/list")
    public Result<List<AppMomentLike>> list(AppMomentLike appMomentLike) {
        Long mid = appMomentLike.getMid();
        if (mid == null) {
            throw new IllegalArgumentException();
        }
        List<AppMomentLike> list = appMomentLikeService.selectAppMomentLikeList(appMomentLike);
        return Result.success(list);
    }


    /**
     * 删除动态喜欢
     */
    @DeleteMapping(value = "/{id}")
    public Result<?> delete(@PathVariable("id") Long id) {
        appMomentLikeService.deleteAppMomentLikeById(id);
        return Result.success();
    }


    /**
     * 新增动态-喜欢
     */
    @Log(title = "动态-喜欢", businessType = BusinessType.INSERT)
    @PostMapping
    public Result<?> add(@RequestBody AppMomentLike appMomentLike) {
        appMomentLikeService.insertAppMomentLike(appMomentLike);
        return Result.success();
    }

}
